package cn.clj.func;

import java.util.Hashtable;

/**
 * CljFunc
 * */
public class MyCljFunc {
    private Boolean isOverride = false;
    private CljFunc cljFunc;
    private Hashtable<Integer, CljFunc> funcOverride;

    public MyCljFunc(Boolean isOverride) {
        this.isOverride = isOverride;
        this.funcOverride = new Hashtable<Integer, CljFunc>();
    }

    public MyCljFunc(CljFunc cljFunc) {
        this.cljFunc = cljFunc;
    }

    public CljFunc getCljFunc(Integer psnum) {
        if (this.getOverride()) {
            CljFunc rs = this.getFuncOverride().get(psnum);
            if (rs != null) {
                return rs;
            } else {
                for (Integer key : this.getFuncOverride().keySet()) {
                    CljFunc c = this.getFuncOverride().get(key);
                    if (c.getFuncParams().size() <= psnum && c.getFuncParams().get(c.getFuncParams().size() - 1).getRestParam() != null)
                    {
                        return c;
                    }
                }
            }
        }
        return null;
    }

    public Boolean getOverride() {
        return isOverride;
    }

    public void setOverride(Boolean override) {
        isOverride = override;
    }

    public CljFunc getCljFunc() {
        return cljFunc;
    }

    public void setCljFunc(CljFunc cljFunc) {
        this.cljFunc = cljFunc;
    }

    public Hashtable<Integer, CljFunc> getFuncOverride() {
        return funcOverride;
    }

    public void setFuncOverride(Hashtable<Integer, CljFunc> funcOverride) {
        this.funcOverride = funcOverride;
    }
}
